<?php

namespace App\Console\Commands;

use App\Models\Divination\Divination;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class Question extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'Question:close';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $date=Carbon::parse('2 days ago')->toDateTimeString();
        $list=Divination::where(['status'=>1])->whereDate('pay_time','<',$date)->get();
        foreach ($list as $item){
            $item->status=3;
            $item->save();
            Log::channel('question')->info('测评订单ID[ '.$item->id.' ]退款完成');
        }
        return Command::SUCCESS;
    }
}
